package com.spring.c_inject.factory;

import com.spring.c_inject.static_factory.IUser;
import com.spring.c_inject.static_factory.IUserImpl;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author restyhap
 * @date 2019年03月07日 14:57
 */
public class UserTest {
    /**
     * 测试通过spring工厂获取实例
     */
    @Test
    public void demo1(){
        BeanFactory bf = new BeanFactory();
        IUserServices iUserServices = bf.getUserServices();
        iUserServices.addUser();
    }
    @Test
    public void demo2(){
        String xmlPath = "beans_c_inject_factory.xml";
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(xmlPath);
        IUserServices iUserServices = context.getBean("userServices",IUserServices.class);
        iUserServices.addUser();
    }
}
